<template>
  <div>
    <el-card>
      <div slot="header" class="clearfix">
        <span>申请列表</span>
      </div>
      <el-table v-loading="loading" :data="list" row-key="id">
        <el-table-column type="index" label="序号"> </el-table-column>
        <el-table-column
          prop="odd"
          label="维修单号"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="createBy"
          label="申请人"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="createDept"
          label="申请部门"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="createTime"
          label="申请时间"
          align="center"
        ></el-table-column>
        <el-table-column prop="auditState" label="审核状态" width="100">
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.audit_state"
              :value="scope.row.auditState"
            />
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              >修改</el-button
            >
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="queryParams.total > 0"
        :total="queryParams.total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
    <AddApply ref="dialogRef" @refresh="getList"></AddApply>
  </div>
</template>
<script>
import { page } from "@/api/prod/repair/apply";
import AddApply from "./components/addApply";

export default {
  name: "ApplyList",
  dicts: ["audit_state"],
  components: { AddApply },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 表格数据
      list: [],
      // 请求参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        // 总数
        total: 0,
      },
      // 选项
      options: [],
    };
  },
  created() {
    this.getList();
  },

  methods: {
    /** 查询申请列表 */
    getList() {
      this.loading = true;
      page(this.queryParams).then((response) => {
        this.list = response.data;
        this.queryParams.total = response.info.total;
        this.loading = false;
      });
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.$refs["dialogRef"].show("修改", null, row.id);
    },
  },
};
</script>

<style>
</style>